package com.xuequ.answerme.manager;

import android.content.Context;

import com.xuequ.answerme.beans.FeedbackBean;
import com.xuequ.answerme.tools.Tools;

import cn.bmob.v3.listener.SaveListener;

/**
 * Created by shijie on 2015/10/27.
 */
public class FeedbackManager {

    public interface SendFeedbackListener{
        void sendFeedbackOnSuccess();
        void sendFeedbackOnFailure(String failureMsg);
    }

    public void sendFeedback(Context context, FeedbackBean feedbackBean, final SendFeedbackListener sendFeedbackListener){
        if(Tools.isNetAvailable(context)){
            feedbackBean.save(context, new SaveListener() {
                @Override
                public void onSuccess() {
                    sendFeedbackListener.sendFeedbackOnSuccess();
                }

                @Override
                public void onFailure(int i, String s) {
                    sendFeedbackListener.sendFeedbackOnFailure(s);
                }
            });
        }else {
            sendFeedbackListener.sendFeedbackOnFailure("网络不可用");
        }
    }

}
